const router = require('koa-router')()
const lists = require('../model/lists')
const koaBody = require('koa-bodyparser');

router.get('/pathlist', async (ctx) => {
    ctx.body = await lists.GETLINE()
    //console.log(ctx.body);
})

router.post('/deletepath',koaBody(),async (ctx) => {
    const id = ctx.request.body.ID
    ctx.body = await lists.DELETELINE(id)
    console.log(ctx.body)
})

router.post('/addpath',koaBody(),async (ctx) => {
    const route = ctx.request.body.route
    const approach = ctx.request.body.approach
    const address = ctx.request.body.address
    const telephone = ctx.request.body.telephone
    ctx.body = await lists.ADDLINE(route,approach,address,telephone)
    console.log(ctx.body)
})

router.post('/updatepath',koaBody(),async (ctx) => {
    const id = ctx.request.body.ID
    const route = ctx.request.body.route
    const approach = ctx.request.body.approach
    const address = ctx.request.body.address
    const telephone = ctx.request.body.telephone
    ctx.body = await lists.UPDATELINE(id,route,approach,address,telephone)
    console.log(ctx.body)
})

module.exports = router